#pragma once
#include "uart/ProtocolSender.h"
#include "can/context.h"
#include <unordered_set>
#include <chrono>
#include "base/log.hpp"
#include "logic_utility.hpp"
#include "uiplayer/ImageAnimView.h"
#include <base/handler.hpp>

UnitStatus unitStatus;
V_Condition condition;

static ui::ImageAnimView *s_tempBrush;
static ui::ImageAnimView *s_fuelBrush;
static ui::ImageAnimView *s_RotationalBrush;

class FaultHandler : public Thread {
public:
    FaultHandler() {}

    void addFaultData(uint16_t FaultID) {
    	Mutex::Autolock lock(mLock);
        if (addFaultInternal(FaultID)) {
            if (!isRunning()) {
                run("fault");
            }
            updateDisplay(FaultID);
        }
    }

    void removeFaultData(uint16_t FaultID) {
    	Mutex::Autolock lock(mLock);
        if (removeFaultInternal(FaultID)) {
            if (fault_ID.empty() && isRunning()) {
                requestExit();
                mWinFaultPtr->hideWnd();
            } else if (fault_ID.size() == 1) {
                // 如果只剩下一条故障信息，则立即显示它
                uint16_t remainingFaultID = *fault_ID.begin();
                updateDisplay(remainingFaultID);
            }
        }
    }

protected:
    bool threadLoop() override {
        while (!exitPending()) {
            std::vector<uint16_t> faultsToDisplay;
            {
            	Mutex::Autolock lock(mLock);

                if (exitPending()) {
                    return false;
                }

                // 复制当前所有的故障到一个临时向量中
                for (const auto& id : fault_ID) {
                    faultsToDisplay.push_back(id);
                }
            }

            // 在不持有锁的情况下更新文本显示
            for (size_t i = 0; i < faultsToDisplay.size(); ++i) {
                if (exitPending()) {
                    return false;
                }
                // 前面的故障显示满三秒再拿锁
                sleep(3000);
                Mutex::Autolock relock(mLock);
                if (fault_ID.find(faultsToDisplay[i]) == fault_ID.end()) {
                    // 如果当前显示的故障已经被移除，直接显示下一个
                    continue;
                }
                updateDisplay(faultsToDisplay[i]);
            }
        }
        return !exitPending();
    }

private:
    bool addFaultInternal(uint16_t FaultID) {
        return fault_ID.emplace(FaultID).second;
    }

    bool removeFaultInternal(uint16_t FaultID) {
        auto it = fault_ID.find(FaultID);
        if (it != fault_ID.end()) {
            fault_ID.erase(it);
            return true;
        }
        return false;
    }

    void updateDisplay(uint16_t FaultID) {
    	mWinFaultPtr->showWnd();
    	char buf[32];
		snprintf(buf, sizeof(buf), "fault_code_%X", FaultID);
		mTextFaultPtr->setTextTr(buf);
    }

    std::unordered_set<uint16_t> fault_ID; // 故障ID集合
    Mutex mLock;                          // 用于保护共享资源
};
static FaultHandler faultHandler;

static Mutex _lock;
static std::unordered_set<CanCallBack> _unit_call;
void AddCallback(CanCallBack updateSetCan)
{
	Mutex::Autolock _l(_lock);
	_unit_call.insert(updateSetCan);
}

void delCallback(CanCallBack updateSetCan){
	Mutex::Autolock _l(_lock);
	_unit_call.erase(updateSetCan);
}
void hideSpeedWin(){
	mWinSpeedPtr->hideWnd();
}
void showSpeedWin(){
	mWinSpeedPtr->showWnd();
}
void hideTachBar(){
	mBurshRotationalPtr->setVisible(false);
}
void showTachBar(){
	mBurshRotationalPtr->setVisible(true);
}
namespace{
	void exeCallback(){
		Mutex::Autolock _l(_lock);
		for (auto it : _unit_call) {
			it();
		}
	}

	CanDataCb _s_can_cb;
	Fault_Indicator status_indicator;      // 故障指示灯
	FaultPrompt status_prompt;			//故障码

	Vehicle_info2 s_info2;
	Vehicle_ODO s_infoODO;
	Vehicle_info1 naviInfo1;

//	void shining2(){
//
//		if(GearFlag){
//			GearFlag = 0;
//			mshiningGearPtr->setVisible(true);
//		}else{
//			GearFlag = 1;
//			mshiningGearPtr->setVisible(false);
//		}
//	}

		int tachNew;
		int tachCur;
		void setSpeedometer()
		{
			mSpeedPtr->setText(naviInfo1.speed_);

		}
		void setTachometer(int rotation)
		{
			s_RotationalBrush->play(rotation);
		}
		//连续线性刷新 转速 表盘，返回false表示到达终点
		bool refreshTach()
		{
			if(tachNew == tachCur){
				return false;
			}
			int sign = 1;
			sign = (tachNew - tachCur) > 0 ? sign : -sign;

			tachCur += sign;

			setTachometer(tachCur);
			return true;
		}

		//线性仪表盘线程
		class Refreshing: public Thread {
		public:
			virtual bool readyToRun() {
				flagTach = true;
//				flagSpd = false;
				return true;
			}
			virtual bool threadLoop() {
				if(flagTach)
				{
					flagTach = refreshTach();
				}else{
					return false;
				}

				usleep(1000 * 10); //50ms
				//返回真，继续下次线程循环
				return true;
			}
			bool flagTach;
//			bool flagSpd;
		};
		Refreshing refreshing;
		void vehicle_info1_cb(Vehicle_info1& canData){
			if(naviInfo1.rotation_ != canData.rotation_){
				naviInfo1.rotation_ = canData.rotation_;
				tachNew = naviInfo1.rotation_ / 100;
			    if(!refreshing.isRunning() && tachNew != tachCur) {
			    	refreshing.run();
			    }
			}
			if(naviInfo1.speed_ != canData.speed_){
				naviInfo1.speed_ = canData.speed_;
				setSpeedometer();
			}
		}

		class MenuController {
		public:
			// 构造函数
			MenuController() : handler_([](const base::message<ZKTextView*>* msg, const void* user_data) {
			    if (msg->what == 66) {
			        msg->obj->setSelected(false);
			    }
			}, this) {}

			void PressKey(ZKTextView* dotPtr) {
				dotPtr->setSelected(true);
				base::message<ZKTextView*> msg(66, dotPtr);
				handler_.send_unique_message_delayed(msg, 200);
			}

		private:
			// 定义 handler 成员变量
			base::handler<ZKTextView*> handler_;
		};
		MenuController menuCtrl;

		void setPositionList(int dot){
			LayoutPosition LayoutList;
			switch(dot){
			case 2:{
				LayoutList = mListViewBarPtr->getPosition();
				LayoutList.mLeft -= 30;
				mListViewBarPtr->setPosition(LayoutList);
			}break;
			case 1:
			case 3:{
				LayoutList = mListViewBarPtr->getPosition();
				LayoutList.mLeft += 30;
				mListViewBarPtr->setPosition(LayoutList);
			}break;
			}
		}
		const uint8_t dotlist[] = { 3, 1, 6, 0, 0, 1, 1, 0, 0};
		int mainID = 0,subID = 0;
		void setActivityWin(key_operation_e& operation){
			char buf[32];
			switch(operation){
			case KEY_UP:{
				mainID = (mainID == 0) ? 8 : mainID - 1;
				subID = 0;
				snprintf(buf, sizeof(buf), "Main_item_%d", mainID);

				mMain_itemPtr->setTextTr(buf);
				if(dotlist[mainID]){
					char buff[32];
					snprintf(buff, sizeof(buff), "Sub_item_%d_%d", mainID,subID);
					mSub_itemPtr->setTextTr(buff);
					mWinSubPtr->showWnd();
				}else{
					mWinSubPtr->hideWnd();
				}

				menuCtrl.PressKey(mButtonUpPtr);
				morderPtr->setText(to_string(mainID+1) + ".");
				if(mainID == 2 || mainID == 1)setPositionList(mainID);
			}break;
			case KEY_DOWN:{
				mainID = (mainID == 8) ? 0 : mainID + 1;
				subID = 0;
				snprintf(buf, sizeof(buf), "Main_item_%d", mainID);
				if(dotlist[mainID]){
					char buff[32];
					snprintf(buff, sizeof(buff), "Sub_item_%d_%d", mainID,subID);
					mSub_itemPtr->setTextTr(buff);
					mWinSubPtr->showWnd();
				}else{
					mWinSubPtr->hideWnd();
				}

				mMain_itemPtr->setTextTr(buf);
				menuCtrl.PressKey(mButtonDownPtr);
				morderPtr->setText(to_string(mainID+1) + ".");
				if(mainID == 2 || mainID == 3)setPositionList(mainID);
			}break;
			case KEY_LEFT:{
				if(dotlist[mainID]){
					subID = (subID == 0) ? dotlist[mainID] : subID - 1;

					snprintf(buf, sizeof(buf), "Sub_item_%d_%d", mainID,subID);
					mSub_itemPtr->setTextTr(buf);
					menuCtrl.PressKey(mButtonLeftPtr);
				}

			}break;
				break;
			case KEY_RIGHT:{
				if(dotlist[mainID]){
					subID = (subID == dotlist[mainID]) ? 0 : subID + 1;

					snprintf(buf, sizeof(buf), "Sub_item_%d_%d", mainID,subID);
					mSub_itemPtr->setTextTr(buf);
					menuCtrl.PressKey(mButtonRightPtr);
				}

			}break;

			default:
				return;
			}
			mListViewBarPtr->refreshListView();
		}

		void key_value_cb(key_value_t& canData){
			if (canData.pre_status == 1 && canData.status == 0)	//短按
			{
				setActivityWin(canData.operation);
			}
//			else if(canData.pre_status == 1 && canData.status == 2)	//长按
//			{
//				LongEnterSet(canData.operation);
//			}
		}
	void setFault0(){
		mGeneratorBatteryPtr->setVisible(status_indicator.fault0.bits.bit3);	//电池
		mbrakingPtr->setVisible(status_indicator.fault0.bits.bit1);	//制动
	}
	void setFault2(){
		mLow_oil_levePtr->setVisible(status_indicator.fault2.bits.bit0);	//油量
		msteeringSystemPtr->setVisible(status_indicator.fault2.bits.bit1);	//转向系统
		mfailurePtr->setVisible(status_indicator.fault2.bits.bit3);		//变速箱故障
		mAutomaticPtr->setVisible(status_indicator.fault2.bits.bit5);		//自动启停
		mElectronic_throttlePtr->setVisible(status_indicator.fault2.bits.bit6);	//节气门
		mECOPtr->setVisible(status_indicator.fault2.bits.bit7);			//ECO
	}
	void setFault3(){
		mAntifreezePtr->setVisible(status_indicator.fault3.bits.bit0);		//防冻液
		mOIL_PRESSUREPtr->setVisible(status_indicator.fault3.bits.bit1);	//机油压力
		mOil_temperaturePtr->setVisible(status_indicator.fault3.bits.bit2);	//机油温度
		mFuel_tankPtr->setVisible(status_indicator.fault3.bits.bit3);	//油箱盖
		mSERVPtr->setVisible(status_indicator.fault3.bits.bit4);
		mLOCKPtr->setVisible(status_indicator.fault3.bits.bit5);
		mWD4LOWPtr->setVisible(status_indicator.fault3.bits.bit6);
		mNEUTRALPtr->setVisible(status_indicator.fault3.bits.bit7);
	}
	void setFault4(){
		mAUTOPtr->setVisible(status_indicator.fault4.bits.bit0);
		mCarDoorPtr->setVisible(!!(status_indicator.fault4.byte & 0x1E));	//有任一未关显示
		mTextDoorRLPtr->setVisible(status_indicator.fault4.bits.bit3);		//左后车门
		mTextDoorRRPtr->setVisible(status_indicator.fault4.bits.bit4);		//右后车门
		mTextDoorFLPtr->setVisible(status_indicator.fault4.bits.bit1);		//左前车门
		mTextDoorFRPtr->setVisible(status_indicator.fault4.bits.bit2);		//右前车门
		mCleaning_liquidPtr->setVisible(status_indicator.fault4.bits.bit5);
		mascend_descendPtr->setVisible(status_indicator.fault4.bits.bit6);
		mTrailer_malfunctionPtr->setVisible(status_indicator.fault4.bits.bit7);
	}
	void setFault5(){
		mdischargePtr->setVisible(status_indicator.fault5.bits.bit0);	//排放
	}
	void fault_indicator_cb(Fault_Indicator& canData){
		if (status_indicator.fault0 != canData.fault0) {
			status_indicator.fault0 = canData.fault0;
			setFault0();
		}
//		if (status_indicator.fault1 != canData.fault1) {
//			status_indicator.fault1 = canData.fault1;
//			setFault0();
//		}
		if (status_indicator.fault2 != canData.fault2) {
			status_indicator.fault2 = canData.fault2;
			setFault2();
		}
		if (status_indicator.fault3 != canData.fault3) {
			status_indicator.fault3 = canData.fault3;
			setFault3();
		}
		if (status_indicator.fault4 != canData.fault4) {
			status_indicator.fault4 = canData.fault4;
			setFault4();
		}
		if (status_indicator.fault5 != canData.fault5) {
			status_indicator.fault5 = canData.fault5;
			setFault5();
		}
	}

	void FaultPrompt_cb(FaultPrompt& canData){
		if(status_prompt.AddOrDel != canData.AddOrDel || status_prompt.FaultID != canData.FaultID){
			status_prompt.AddOrDel = canData.AddOrDel;
			status_prompt.FaultID = canData.FaultID;
			if(status_prompt.AddOrDel == 0x1A52){
//				LOGI_TRACE("准备添加 fault_code_%X", status_prompt.FaultID);
				faultHandler.addFaultData(status_prompt.FaultID);
			}else if(status_prompt.AddOrDel == 0x1A55){
				faultHandler.removeFaultData(status_prompt.FaultID);
//				LOGW_TRACE("准备移除 fault_code_%X", status_prompt.FaultID);
			}
		}
	}
	void setCompass(){
		switch (condition.compass){
		case 0:
			mcompassPtr->setText("N");
			break;
		case 1:
			mcompassPtr->setText("NE");
			break;
		case 2:
			mcompassPtr->setText("E");
			break;
		case 3:
			mcompassPtr->setText("SE");
			break;
		case 4:
			mcompassPtr->setText("S");
			break;
		case 5:
			mcompassPtr->setText("SW");
			break;
		case 6:
			mcompassPtr->setText("W");
			break;
		case 7:
			mcompassPtr->setText("NW");
			break;
		default:
			mcompassPtr->setText("--");
			break;
		}
	}
	bool isRegistered = false;
	void condition_cb(V_Condition& canData){
		if (condition.compass != canData.compass) {
			condition.compass = canData.compass;
			setCompass();
		}
		if(condition.gear != canData.gear || condition.gearGrade != canData.gearGrade || condition.gearRank != canData.gearRank){
			condition.gear = canData.gear; condition.gearGrade = canData.gearGrade; condition.gearRank = canData.gearRank;
			setGear(mgearPtr,mgearRankPtr,isRegistered);
		}
	}
	void set_uint(){
		if(unitStatus.s_speed){
			mspeedUnitPtr->setText("mph");
		}else{
			mspeedUnitPtr->setText("km/h");
		}
	}
	void UnitStatus_cb(UnitStatus& canData){
		if (unitStatus.s_distance != canData.s_distance) {
			unitStatus.s_distance = canData.s_distance;
			exeCallback();
		}
		if (unitStatus.s_fuel != canData.s_fuel) {
			unitStatus.s_fuel = canData.s_fuel;
			exeCallback();
		}
		if (unitStatus.s_pressure != canData.s_pressure) {
			unitStatus.s_pressure = canData.s_pressure;
			exeCallback();
		}
		if (unitStatus.s_speed != canData.s_speed) {
			unitStatus.s_speed = canData.s_speed;
			set_uint();
			exeCallback();
		}
		if (unitStatus.s_temperature != canData.s_temperature) {
			unitStatus.s_temperature = canData.s_temperature;
			exeCallback();
		}
	}
	// 定义温度区间和对应的进度
	struct TemperatureRange {
	    uint16_t startTemp;
	    uint16_t endTemp;
	    double baseProgress;
	};
	// 摄氏度温度区间 (原始数据)
	const TemperatureRange celsiusRanges[] = {
	    {0x00, 0x49, 0},     // 0x00-0x54 -> 0%
		{0x50, 0x54, 0},
	    {0x55, 0x5F, 12.5},  // 0x55-0x5F -> 12.5%
	    {0x60, 0x6A, 25},    // 0x60-0x6A -> 25%
	    {0x6B, 0x9A, 37.5},  // 0x6B-0x9A -> 37.5%
	    {0x9B, 0x9E, 50},    // 0x9B-0x9E -> 50%
	    {0x9F, 0xA1, 62.5},  // 0x9F-0xA1 -> 62.5%
	    {0xA2, 0xA5, 75},    // 0xA2-0xA5 -> 75%
	    {0xA6, 0xAA, 87.5},  // 0xA6-0xAA -> 87.5%
	    {0xAB, 0xFFFE, 100}  // 0xAB-0xFFFE -> 100%
	};

	// 华氏度温度区间 (原始数据)
	const TemperatureRange fahrenheitRanges[] = {
	    {0x00, 0x89, 0},     // 0x00-0x98 -> 0%
		{0x90, 0x98, 0},
	    {0x99, 0xAB, 12.5},  // 0x99-0xAB -> 12.5%
	    {0xAC, 0xBF, 25},    // 0xAC-0xBF -> 25%
	    {0xC0, 0x116, 37.5}, // 0xC0-0x116 -> 37.5%
	    {0x117, 0x11D, 50},  // 0x117-0x11D -> 50%
	    {0x11E, 0x122, 62.5},// 0x11E-0x122 -> 62.5%
	    {0x123, 0x129, 75},  // 0x123-0x129 -> 75%
	    {0x12A, 0x132, 87.5},// 0x12A-0x132 -> 87.5%
	    {0x133, 0xFFFE, 100}// 0x133-0xFFFE -> 100%
	};

	int calculateProgress(uint16_t temperature, const TemperatureRange* ranges, size_t rangeCount) {

	    for (size_t i = 0; i < rangeCount; ++i) {
	        if (temperature >= ranges[i].startTemp && temperature <= ranges[i].endTemp) {
	            // 如果是最后一个区间或者温度正好等于开始温度，则直接返回进度
	            if (i == rangeCount - 1 || temperature == ranges[i].startTemp) {
	                return static_cast<int>(ranges[i].baseProgress);
	            }
	            // 否则进行线性插值
	            double fraction = static_cast<double>(temperature - ranges[i].startTemp) /
	                              (ranges[i].endTemp - ranges[i].startTemp);
	            return static_cast<int>(ranges[i].baseProgress + fraction * (ranges[i + 1].baseProgress - ranges[i].baseProgress));
	        }
	    }
	    // 如果温度超出所有定义的范围，则返回默认值
	    return 0;
	}

	void setCoolant(int Temperature) {
	    const TemperatureRange* ranges = (unitStatus.s_temperature == CELSIUS) ? celsiusRanges : fahrenheitRanges;

	    int progress = calculateProgress(static_cast<uint16_t>(Temperature), ranges, 10);

	    s_tempBrush->play(progress);

	}
	void setOilPercent(){
		s_fuelBrush->play(s_info2.Oil_percentage);
	}
	void setRange(){
		if(s_info2.RangeEndurance == 0xFFFF){
			mrangePtr->setText("----");
		}else if(s_info2.RangeEndurance == 0xFFFE){
			mrangePtr->setText("FuelLow");
		}else{
			if(unitStatus.s_distance){
				mrangePtr->setText(to_string(s_info2.RangeEndurance) + "mile");
			}else{
				mrangePtr->setText(to_string(s_info2.RangeEndurance) + "km");
			}
		}
	}
	void vehicle_info2_cb(Vehicle_info2& canData){
		if(s_info2.CoolantTemperature != canData.CoolantTemperature){
			s_info2.CoolantTemperature = canData.CoolantTemperature;
			setCoolant(s_info2.CoolantTemperature);
		}
		if(s_info2.Oil_percentage != canData.Oil_percentage){
			s_info2.Oil_percentage = canData.Oil_percentage;
			setOilPercent();
		}
		if(s_info2.RangeEndurance != canData.RangeEndurance){
			s_info2.RangeEndurance = canData.RangeEndurance;
			setRange();
		}
	}
	void setODO(){
		if(unitStatus.s_distance){
			mmileageTotalPtr->setText(to_string(s_infoODO.odo) + "mile");
		}else{
			mmileageTotalPtr->setText(to_string(s_infoODO.odo) + "km");
		}
	}
	void vehicle_odo_cb(Vehicle_ODO& canData){
		if(s_infoODO.odo != canData.odo){
			s_infoODO.odo = canData.odo;
			setODO();
		}
	}

	void _can_add_cb() {
		_s_can_cb.fault_indicator_cb = fault_indicator_cb;
		_s_can_cb.FaultPrompt_cb = FaultPrompt_cb;
		_s_can_cb.condition_cb = condition_cb;
		_s_can_cb.UnitStatus_cb = UnitStatus_cb;
		_s_can_cb.vehicle_info2_cb = vehicle_info2_cb;
		_s_can_cb.vehicle_odo_cb = vehicle_odo_cb;
		_s_can_cb.vehicle_info1_cb = vehicle_info1_cb;
		_s_can_cb.key_value_cb = key_value_cb;
		can::add_cb(&_s_can_cb);
	}

	void _can_remove_cb() {
		can::remove_cb(&_s_can_cb);
	}
	void Initialization(){
		set_uint();
		setODO();
		setCoolant(s_info2.CoolantTemperature);
		setOilPercent();
		setFault0();
		setFault2();
		setFault3();
		setFault4();
		setFault5();
		setCompass();
		mWinFaultPtr->hideWnd();
		setRange();
		setGear(mgearPtr,mgearRankPtr,isRegistered);
		tachNew = naviInfo1.rotation_ / 100;
		setTachometer(tachNew);
		setSpeedometer();
	}
	void setFont(){
		setCtrlFont(mgearRankPtr);
		setCtrlFont(mTextView4Ptr);
		setCtrlFont(mmileageTotalPtr);
		setCtrlFont(mTextView3Ptr);
		mrangePtr->setFontFamily("anago-bold");
		setCtrlFont(mSpeedPtr);
		setCtrlFont(mspeedUnitPtr);
		setCtrlFont(mMain_itemPtr);
		setCtrlFont(mSub_itemPtr);
		setCtrlFont(morderPtr);
	}
}
static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {

};

/**
 * 当界面构造时触发
 */
static void onUI_init(){
	_can_add_cb();
	setFont();

	s_tempBrush = new ui::ImageAnimView(mWinCoolantPtr, 81, { 0, 0, 192, 242 });
	s_fuelBrush = new ui::ImageAnimView(mWinFuelPtr, 82, { 0,0, 192, 242 });
	s_RotationalBrush = new ui::ImageAnimView(mBurshRotationalPtr, 83, { 0, 0, 1128, 116 });

	s_RotationalBrush->load(CONFIGMANAGER->getResFilePath("ZbrushMap/mode1Rotational"));
	s_tempBrush->load(CONFIGMANAGER->getResFilePath("ZbrushMap/SetCoolant"));
	s_fuelBrush->load(CONFIGMANAGER->getResFilePath("ZbrushMap/SetFuel"));
	Initialization();
}

/*
 * 当界面完全退出时触发
 */
static void onUI_quit() {
	_can_remove_cb();
	delete s_tempBrush;
	delete s_fuelBrush;
	delete s_RotationalBrush;
}

/**
 * 串口数据回调接口
 */
static void onProtocolDataUpdate(const SProtocolData &data) {
    //串口数据回调接口
}

/**
 * 定时器触发函数
 * 不建议在此函数中写耗时操作，否则将影响UI刷新
 * 参数： id
 *         当前所触发定时器的id，与注册时的id相同
 * 返回值: true
 *             继续运行当前定时器
 *         false
 *             停止运行当前定时器
 */
static bool onUI_Timer(int id){
	switch (id) {
//	case 0:
//		exeGearback();
//		break;
	default:
			break;
	}
    return true;
}

/**
 * 有新的触摸事件时触发
 * 参数：ev
 *         新的触摸事件
 * 返回值：true
 *            表示该触摸事件在此被拦截，系统不再将此触摸事件传递到控件上
 *         false
 *            触摸事件将继续传递到控件上
 */
static bool onstatusbarActivityTouchEvent(const MotionEvent &ev) {
    switch (ev.mActionStatus) {
		case MotionEvent::E_ACTION_DOWN://触摸按下
			//LOGD("时刻 = %ld 坐标  x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
			break;
		case MotionEvent::E_ACTION_MOVE://触摸滑动
			break;
		case MotionEvent::E_ACTION_UP:  //触摸抬起
			break;
		default:
			break;
	}
	return false;
}


static int getListItemCount_ListViewBar(const ZKListView *pListView) {
    //LOGD("getListItemCount_ListViewBar !\n");
	return dotlist[mainID] + 1;
}

static void obtainListItemData_ListViewBar(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
    //LOGD(" obtainListItemData_ ListViewBar  !!!\n");
	pListItem->setSelected(subID == index);
}

static void onListItemClick_ListViewBar(ZKListView *pListView, int index, int id) {
    //LOGD(" onListItemClick_ ListViewBar  !!!\n");
}

static bool onButtonClick_ButtonUp(ZKButton *pButton) {
    LOGD(" ButtonClick ButtonUp !!!\n");
    return false;
}

static bool onButtonClick_ButtonDown(ZKButton *pButton) {
    LOGD(" ButtonClick ButtonDown !!!\n");
    return false;
}

static bool onButtonClick_ButtonLeft(ZKButton *pButton) {
    LOGD(" ButtonClick ButtonLeft !!!\n");
    return false;
}

static bool onButtonClick_ButtonRight(ZKButton *pButton) {
    LOGD(" ButtonClick ButtonRight !!!\n");
    return false;
}
